package com.weixiaoit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.weixiaoit.ajax.util.DBHelp;
import com.weixiaoit.ajax.util.RowMapper;
import com.weixiaoit.entity.Province;

public class ProvinceDao {
	DBHelp<Province> db=new DBHelp<Province>();
	public List<Province>findAll() {
		String sql="select id,province from t_province";
		return db.executeQueryForList(sql, new ProvinceRowMapper() );
	}
	private class ProvinceRowMapper implements RowMapper<Province>{

		public Province mapperRow(ResultSet rs) throws SQLException {
			Province pc=new Province();
			pc.setId(rs.getString("id"));
			pc.setProvince(rs.getString("province"));
			return pc;
		}
		
		
	}
	public Province findByProvince(String province) {
		String sql="SELECT id,province FROM t_province WHERE  province=?";
		return db.executeQueryForObject(sql, new ProvinceRowMapper(), province);
	}

}
